package Ch4;

/**
 * Created by Cai Ye on 2016/3/26.
 */
public class InterfaceMulitChat {
    public static void main(String[] args) {
        InterfaceClient c1 = new InterfaceClient("127.0.0.1", "Caterpillar");
        InterfaceClient c2 = new InterfaceClient("192.168.0.2", "Justin");
        InterfaceClientQueue queue = new InterfaceClientQueue();
        queue.addInterfaceClientListener(new InterfaceClientListener() {
            @Override
            public void clientAdded(InterfaceClientEvent event) {
                System.out.printf("%s 从 %s 联机%n", event.getName(), event.getIp());
            }

            @Override
            public void clientRemoved(InterfaceClientEvent event) {
                System.out.printf("%s 从 %s 脱机%n", event.getName(), event.getIp());
            }
        });
        queue.add(c1);
        queue.add(c2);
        queue.removed(c1);
        queue.removed(c2);
    }
}
